package com.hhxy.consumer;

import com.hhxy.utils.RabbitMqUtil;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ghp
 * @date 2023/2/27
 * @title
 * @description
 */
@Slf4j
public class PriorityConsumer {

    private final static String QUEUE_NAME = "priority.queue";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtil.getChannel();

        // 发送消息
        DeliverCallback deliverCallback = (consumerTag, delivery) -> {
            String message = new String(delivery.getBody());
            log.info("消费者PriorityConsumer接收消息:{}, 消息tag为:{}", message, consumerTag);
        };
        CancelCallback cancelCallback = (consumerTag) -> {
            log.info("消息消费过程被中断！");
        };
        channel.basicConsume(QUEUE_NAME, true, deliverCallback, cancelCallback);
    }
}